/**
 * 2018年11月25日下午11:28:03
 * @author 谢进财
 */
package com.baihang.framework.dao;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 数据记录
 *
 */
public class Record extends BaseRecord implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Map<String, Object> columns=new HashMap<String,Object>();
	
	public Map<String, Object> getColumns() {
		return columns;
	}

	public  Record() {};
	
	public  Record(Map<String, Object> columns) {
		this.columns=columns;
	}
	
	public Record setColumns(Map<String, Object> columns) {
		this.columns.putAll(columns);
		return this;
	}
	
	/**
	 * Set column to record.
	 * @param column the column name
	 * @param value the value of the column
	 */
	public Record set(String column, Object value) {
		getColumns().put(column, value);
		return this;
	}
	/**
	 * Get column of mysql type: varchar, char, enum, set, text, tinytext, mediumtext, longtext
	 */
	public String getStr(String column) {
		return (String)columns.get(column);
	}
	
	/**
	 * Get column of mysql type: int, integer, tinyint(n) n > 1, smallint, mediumint
	 */
	public Integer getInt(String column) {
		return (Integer)columns.get(column);
	}
	
	/**
	 * Get column of mysql type: bigint
	 */
	public Long getLong(String column) {
		return (Long)columns.get(column);
	}
	public BigDecimal getBigDecimal(String column) {
		return (BigDecimal)columns.get(column);
	}
	public Float getFloat(String column) {
		return (Float)columns.get(column);
	}
	public Double getDouble(String column) {
		return (Double)columns.get(column);
	}
}
